home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / lightning-0.8-tb-win.xpi / chrome / calendar.jar / content / calendar / calendar-alarm-widget.xml < prev    next >
Extensible Markup Language  |  2008-01-26  |  10KB  |  221 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.    - ***** BEGIN LICENSE BLOCK *****
  4.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.    -
  6.    - The contents of this file are subject to the Mozilla Public License Version
  7.    - 1.1 (the "License"); you may not use this file except in compliance with
  8.    - the License. You may obtain a copy of the License at
  9.    - http://www.mozilla.org/MPL/
  10.    -
  11.    - Software distributed under the License is distributed on an "AS IS" basis,
  12.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.    - for the specific language governing rights and limitations under the
  14.    - License.
  15.    -
  16.    - The Original Code is calendar views.
  17.    -
  18.    - The Initial Developer of the Original Code is Oracle Corporation
  19.    - Portions created by the Initial Developer are Copyright (C) 2005
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Stuart Parmenter <stuart.parmenter@oracle.com>
  24.    -   Simon Paquet <bugzilla@babylonsounds.com>
  25.    -   Joey Minta <jminta@gmail.com>
  26.    -   Stefan Sitter <ssitter@googlemail.com>
  27.    -   Philipp Kewisch <mozilla@kewis.ch>
  28.    -
  29.    - Alternatively, the contents of this file may be used under the terms of
  30.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  31.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  32.    - in which case the provisions of the GPL or the LGPL are applicable instead
  33.    - of those above. If you wish to allow use of your version of this file only
  34.    - under the terms of either the GPL or the LGPL, and not to allow others to
  35.    - use your version of this file under the terms of the MPL, indicate your
  36.    - decision by deleting the provisions above and replace them with the notice
  37.    - and other provisions required by the GPL or the LGPL. If you do not delete
  38.    - the provisions above, a recipient may use your version of this file under
  39.    - the terms of any one of the MPL, the GPL or the LGPL.
  40.    -
  41.    - ***** END LICENSE BLOCK ***** -->
  42.  
  43. <!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
  44.  
  45. <bindings id="calendar-alarms"
  46.    xmlns="http://www.mozilla.org/xbl"
  47.    xmlns:xbl="http://www.mozilla.org/xbl"
  48.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  49.  
  50.   <binding id="calendar-alarm-widget" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
  51.     <resources>
  52.       <stylesheet src="chrome://global/skin/button.css"/>
  53.       <stylesheet src="chrome://calendar/skin/calendar-alarm-dialog.css"/>
  54.     </resources>
  55.  
  56.     <content>
  57.       <xul:hbox flex="1">
  58.         <xul:vbox pack="start">
  59.           <xul:image class="alarm-calendar-image"/>
  60.         </xul:vbox>
  61.         <xul:vbox>
  62.           <xul:label anonid="alarm-title-label" class="alarm-title-label" crop="end"/>
  63.           <xul:vbox class="additional-information-box">
  64.             <xul:label anonid="alarm-date-label" class="alarm-date-label"/>
  65.             <xul:hbox>
  66.               <xul:label anonid="alarm-location-label" class="location-label">&calendar.alarm.location.label;</xul:label>
  67.               <xul:description anonid="alarm-location-description" class="alarm-location-description" crop="end"/>
  68.             </xul:hbox>
  69.             <xul:hbox pack="start">
  70.               <xul:label class="text-link alarm-details-label"
  71.                      value="&calendar.alarm.details.label;"
  72.                      onclick="showDetails(event)"
  73.                      onkeypress="showDetails(event)"/>
  74.             </xul:hbox>
  75.           </xul:vbox>
  76.         </xul:vbox>
  77.         <xul:spacer flex="1"/>
  78.         <xul:label anonid="alarm-relative-date-label" class="alarm-relative-date-label"/>
  79.         <xul:vbox class="alarm-action-buttons" pack="center">
  80.           <xul:button anonid="alarm-snooze-button"
  81.                       oncommand="_openSnoozeWindow(event); return false;">
  82.             <xul:label class="button-text" value="&calendar.alarm.snoozefor.label;"/>
  83.             <xul:dropmarker class="button-menu-dropmarker"/>
  84.           </xul:button>
  85.           <xul:button anonid="alarm-dismiss-button"
  86.                       label="&calendar.alarm.dismiss.label;"
  87.                       oncommand="dismissAlarm()"/>
  88.         </xul:vbox>
  89.       </xul:hbox>
  90.     </content>
  91.  
  92.     <implementation>
  93.       <field name="mItem">null</field>
  94.  
  95.       <property name="item">
  96.         <getter><![CDATA[
  97.           return this.mItem;
  98.         ]]></getter>
  99.         <setter><![CDATA[
  100.           this.mItem = val;
  101.           var formatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
  102.                                     .getService(Components.interfaces.calIDateTimeFormatter);
  103.           var titleLabel = document.getAnonymousElementByAttribute(this, "anonid", "alarm-title-label");
  104.           var locationDescription = document.getAnonymousElementByAttribute(this, "anonid", "alarm-location-description");
  105.           var dateLabel = document.getAnonymousElementByAttribute(this, "anonid", "alarm-date-label");
  106.  
  107.           // Dates
  108.           var startString = {};
  109.           var endString = {};
  110.  
  111.           if (this.mItem instanceof Components.interfaces.calIEvent) {
  112.               var startDate = val.startDate.getInTimezone(calendarDefaultTimezone());
  113.               var endDate = val.endDate.getInTimezone(calendarDefaultTimezone());
  114.               formatter.formatInterval(startDate, endDate, startString, endString);
  115.               dateLabel.textContent = startString.value +
  116.                                       (endString.value ? ' - ' + endString.value : "");
  117.           } else if (val instanceof Components.interfaces.calITodo) {
  118.               var startDate = val.entryDate || val.dueDate;
  119.               startDate = startDate.getInTimezone(calendarDefaultTimezone());
  120.               dateLabel.textContent = calGetString("calendar",
  121.                                                    "alarmStarts",
  122.                                                    [formatter.formatDateTime(startDate)]);
  123.           } else {
  124.               throw Components.results.NS_ERROR_ILLEGAL_VALUE;
  125.           }
  126.  
  127.           // Relative date
  128.           this.updateRelativeDateLabel();
  129.  
  130.           // Title, location
  131.           titleLabel.value = val.title || "";
  132.           locationDescription.value = val.getProperty("LOCATION") || "";
  133.           locationDescription.hidden = (locationDescription.value.length < 1);
  134.  
  135.           document.getAnonymousElementByAttribute(this, "anonid", "alarm-location-label").hidden =
  136.               (locationDescription.value.length < 1);
  137.  
  138.           return val;
  139.         ]]></setter>
  140.       </property>
  141.  
  142.       <method name="updateRelativeDateLabel">
  143.         <body><![CDATA[
  144.           var formatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
  145.                                     .getService(Components.interfaces.calIDateTimeFormatter);
  146.           var relativeDateLabel = document.getAnonymousElementByAttribute(this, "anonid", "alarm-relative-date-label");
  147.           var relativeDateString;
  148.           var startDate = (this.mItem.startDate || this.mItem.entryDate || this.mItem.dueDate);
  149.           startDate = startDate.getInTimezone(calendarDefaultTimezone());
  150.           var currentDate = now();
  151.           var sinceDayStart = (currentDate.hour * 3600) + (currentDate.minute * 60);
  152.  
  153.           currentDate.second = 0;
  154.           startDate.second = 0;
  155.  
  156.           var sinceAlarm = currentDate.subtractDate(startDate).inSeconds;
  157.  
  158.           this.mAlarmToday = (sinceAlarm < sinceDayStart) && (sinceAlarm > sinceDayStart - 86400);
  159.  
  160.           if (this.mAlarmToday) {
  161.               // The alarm is today
  162.               relativeDateString = calGetString("calendar",
  163.                                                 "alarmTodayAt",
  164.                                                 [formatter.formatTime(startDate)]);
  165.           } else if (sinceAlarm < sinceDayStart + 86400 && sinceAlarm > sinceDayStart) {
  166.               // The alarm is yesterday
  167.               relativeDateString = calGetString("calendar",
  168.                                                 "alarmYesterdayAt",
  169.                                                 [formatter.formatTime(startDate)]);
  170.           } else {
  171.               // The alarm is way back
  172.               relativeDateString = [formatter.formatDateTime(startDate)];
  173.           }
  174.  
  175.           relativeDateLabel.textContent = relativeDateString;
  176.         ]]></body>
  177.       </method>
  178.  
  179.       <method name="showDetails">
  180.         <parameter name="event"/>
  181.         <body><![CDATA[
  182.           if (event.type == "click" ||
  183.               (event.type == "keypress" &&
  184.                (event.keyCode == event.DOM_VK_ENTER ||
  185.                 event.keyCode == event.DOM_VK_RETURN))) {
  186.               var detailsEvent = document.createEvent('Events');
  187.               detailsEvent.initEvent('itemdetails', true, false);
  188.               this.dispatchEvent(detailsEvent);
  189.           }
  190.         ]]></body>
  191.       </method>
  192.  
  193.       <method name="snoozeAlarm">
  194.         <parameter name="minutes"/>
  195.         <body><![CDATA[
  196.           var snoozeEvent = document.createEvent('Events');
  197.           snoozeEvent.initEvent('snooze', true, false);
  198.           snoozeEvent.detail = minutes;
  199.           this.dispatchEvent(snoozeEvent);
  200.         ]]></body>
  201.       </method>
  202.  
  203.       <method name="dismissAlarm">
  204.         <body><![CDATA[
  205.           var dismissEvent = document.createEvent('Events');
  206.           dismissEvent.initEvent('dismiss', true, false);
  207.           this.dispatchEvent(dismissEvent);
  208.         ]]></body>
  209.       </method>
  210.  
  211.       <method name="_openSnoozeWindow">
  212.         <parameter name="event"/>
  213.         <body><![CDATA[
  214.           // Call the function from calendar-alarm-dialog.js
  215.           openSnoozeWindow(event, this); 
  216.         ]]></body>
  217.       </method>
  218.     </implementation>
  219.   </binding>
  220. </bindings>
  221.